﻿IF EXISTS (
    SELECT
      1
    FROM sysobjects
    WHERE id = OBJECT_ID('bd_proc_timecard_extend')
      AND type IN ('P', 'PC')
  )
  DROP PROCEDURE bd_proc_timecard_extend

GO

-- =============================================
-- Author:      YFC
-- Create date: 2020-01-17 10:14:16
-- Database:    scm_main_dev
-- Description: 考勤管理-考勤卡重新计算
--                加班工时确认、请假取消处理后调用重新计算考勤
-- =============================================
CREATE PROCEDURE bd_proc_timecard_extend
  @BeginDate DATE
 ,@EndDate DATE
 ,@users VARCHAR(MAX)
 ,@flag INT = 0
AS
BEGIN
  SET NOCOUNT ON;

  DECLARE @i INT = 1

  WHILE (@BeginDate <= @EndDate)
  BEGIN

    PRINT(@BeginDate)

    EXEC bd_proc_timecard @BeginDate
                         ,@users, @flag
  
    SET @BeginDate = CONVERT(VARCHAR(10), DATEADD(DAY, 1, @BeginDate), 120)

  END

  SET NOCOUNT OFF;
END